//
// Created by mio on 25-5-7.
//

#ifndef LOADBLANCECONNECTION_H
#define LOADBLANCECONNECTION_H

#include "LoadBlanceServer.h"
#include "../Net/TcpConnection.h"

class LoadBlanceConnection : public TcpConnection
{
public:
    LoadBlanceConnection(std::weak_ptr<LoadBlanceServer> loadblance_server,TaskScheduler* task_scheduler, int sockfd);
    ~LoadBlanceConnection();

protected:
    bool OnRead(BufferReader& buffer);
    void DisConnection();
    bool IsTimeout(uint64_t timestamp);
    void HandleMessage(BufferReader& buffer);
    void HandleLogin(BufferReader& buffer);
    void HandleMonitorInfo(BufferReader& buffer);

private:
    int socket_;
    std::weak_ptr<LoadBlanceServer> loadblance_server_;
};

#endif //LOADBLANCECONNECTION_H